package com.acme.bankapp.domain.bank.account;

/**
 * This class implements {@link AbstractAccount} interface for clients with overdraft
 *
 * @author Alexander Kotov
 */

public class CheckingAccount extends AbstractAccount {

    private final double overdraft;

    public CheckingAccount(double balance, double overdraft) {
        super(balance);
        this.overdraft = overdraft;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void withdraw(double amount) {
        if (balance + overdraft >= amount) {
            balance -= amount;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public double getMaximumAmountToWithdraw() {
        return balance + overdraft;
    }
}
